// index.js
Component({
	properties: {
		tpurl: {
			type: String,
			value: ''
		},
		spurl: {
			type: String,
			value: ''
		},
		flag: {
			type: Boolean,
			value: ''
		}
	},
	data: {
		intervalId: null,
	},
	methods: {

		handleReady: function({
			detail
		}) {
			const xrScene = this.scene = detail.value;
			console.log('xr-scene', xrScene);

			let that = this;
			this.data.intervalId = setInterval(function() {
				if (that.properties.flag) {
					
					that.handleShare();
				} else {
					clearTimeout(that.data.intervalId);
				}

			}, 700);
		//	this.scene.event.add('touchstart', this.handleShare.bind(this));
		},
		handleAssetsProgress: function({
			detail
		}) {
			console.log('assets progress', detail.value);
		},
		handleAssetsLoaded: function({
			detail
		}) {
			this.setData({
				loaded: true
			});
		},
		handleTrackerSwitch: function({
			detail
		}) {
			const active = detail.value;
			const video = this.scene.assets.getAsset('video-texture', 'hikari');
			// const video = this.scene.assets.getAsset('gltf', 'hikari');
			active ? video.play() : video.stop();
		},
		async handleShare() {
			let that = this;
			const options = {
				type: 'jpg',
				quality: 0.7
			};
			const base64 = await that.scene.share.captureToDataURLAsync(options);

			that.triggerEvent("startBase64", base64)

		},



	}
})